using System;
using Microsoft.SharePoint;

namespace SharePoint.DataMapper
{
	[FieldMapper(typeof(SPFieldCurrency), SPFieldType.Currency)]
	public class FieldCurrencyMapper : FieldNumberMapper
	{
		protected override SPField AddFieldInternal(ListDataContext context, SPFieldCollection collection, Type propertyType, FieldAttribute attribute)
		{
			SPFieldCurrency field = (SPFieldCurrency)base.AddFieldInternal(context, collection, propertyType, attribute);
			field.CurrencyLocaleId = attribute.CurrencyLocaleId;
			return field;
		}

		protected override FieldAttribute GetFieldAttributeInternal(SPField field)
		{
			FieldAttribute attribute = base.GetFieldAttributeInternal(field);
			SPFieldCurrency fieldCurrency = field as SPFieldCurrency;
			if (fieldCurrency == null)
			{
				return attribute;
			}
			attribute.CurrencyLocaleId = fieldCurrency.CurrencyLocaleId;
			return attribute;
		}

	}
}